/*
https://leetcode-cn.com/problems/shuffle-an-array/solution/da-luan-shu-zu-by-leetcode-solution-og5u/
 */
import java.util.Arrays;

public class Solution384 {

    int[] nums;
    int[] ans;

    public Solution384(int[] nums) {
        this.nums=nums;
    }

    public int[] reset() {
        ans=Arrays.copyOf(nums,nums.length);
        return ans;
    }

    public int[] shuffle() {
        ans=Arrays.copyOf(nums,nums.length);
        for (int i=0;i<ans.length;i++){
            int t=(int)(Math.random()*(ans.length-i))+i;
            int temp=ans[t];
            ans[t]=ans[i];
            ans[i]=temp;
        }
        return ans;
    }

    public static void main(String[] args) {
        Solution384 solution384=new Solution384(new int[]{1,2,3});
        System.out.println(Arrays.toString(solution384.shuffle()));
        System.out.println(Arrays.toString(solution384.reset()));
    }
}
